package com.spark.lola.statistics.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.spark.lola.support.common.util.TimeUtil;
import com.spark.lola.support.mybatis.entity.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author: Zhi-peng wang
 * @date: 2020/05/14 11:18
 * 车辆货运总量统计信息
 **/
@Getter
@Setter
@ApiModel(value = "StatisticsCar", description = "车辆货运总量统计信息")
@TableName("statistics_car")
public class StatisticsCar extends BaseModel {

    @ApiModelProperty(name = "carId", value = "车辆id")
    @ExcelProperty("车辆id")
    private Long carId;

    @ApiModelProperty(name = "carNo", value = "车牌号")
    @ExcelProperty("车牌号")
    @TableField(exist = false)
    private String carNo;

    @ApiModelProperty(name = "logisticsNumber", value = "货运数量")
    @ExcelProperty("货运数量")
    private Integer logisticsNumber;

    @ApiModelProperty(name = "logisticsMoney", value = "货运总金额")
    @ExcelProperty("货运总金额")
    private BigDecimal logisticsMoney;

    @ApiModelProperty(name = "logisticsSettlementMoney", value = "货运已结算金额")
    @ExcelProperty("货运已结算金额")
    private BigDecimal logisticsSettlementMoney;

    @ApiModelProperty(name = "logisticsNotSettlementMoney", value = "货运未结算金额")
    @ExcelProperty("货运未结算金额")
    private BigDecimal logisticsNotSettlementMoney;

    @ApiModelProperty(name = "logisticsExpensesMoney", value = "货运支出总金额")
    @ExcelProperty("货运支出总金额")
    private BigDecimal expensesMoney;

    @ApiModelProperty(name = "logisticsExpensesSettlementMoney", value = "已结算货运支出金额")
    @ExcelProperty("已结算货运支出金额")
    private BigDecimal expensesSettlementMoney;

    @ApiModelProperty(name = "logisticsExpensesNotSettlementMoney", value = "未结算货运支出金额")
    @ExcelProperty("未结算货运支出金额")
    private BigDecimal expensesNotSettlementMoney;

    @ApiModelProperty(name = "logisticsTotalWeight", value = "货运总重（t）")
    @ExcelProperty("货运总重（t）")
    private BigDecimal logisticsTotalWeight;

    @ApiModelProperty(name = "logisticsMileage", value = "货运里程")
    @ExcelProperty("货运里程")
    private Integer logisticsMileage;

    @ApiModelProperty(name = "createDate", value = "创建日期 yyyy-MM-dd")
    @ExcelProperty("创建日期 yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createDate;

    @ApiModelProperty(name = "createMonth", value = "创建月份 yyyyMM")
    @ExcelProperty("创建月份 yyyyMM")
    private Integer createMonth;

    @ApiModelProperty(name = "createYear", value = "创建年份yyyy")
    @ExcelProperty("创建年份yyyy")
    private Integer createYear;

    @ApiModelProperty(name = "updateTime", value = "修改时间")
    @ExcelProperty("修改时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    public StatisticsCar() {
        this.logisticsNumber = 0;
        this.logisticsMoney = BigDecimal.ZERO;
        this.logisticsSettlementMoney = BigDecimal.ZERO;
        this.logisticsNotSettlementMoney = BigDecimal.ZERO;
        this.expensesMoney = BigDecimal.ZERO;
        this.expensesSettlementMoney = BigDecimal.ZERO;
        this.expensesNotSettlementMoney = BigDecimal.ZERO;
        this.logisticsTotalWeight = BigDecimal.ZERO;
        this.logisticsMileage = 0;
    }

    public StatisticsCar(Date date) {
        this.logisticsNumber = 0;
        this.logisticsMoney = BigDecimal.ZERO;
        this.logisticsSettlementMoney = BigDecimal.ZERO;
        this.logisticsNotSettlementMoney = BigDecimal.ZERO;
        this.expensesMoney = BigDecimal.ZERO;
        this.expensesSettlementMoney = BigDecimal.ZERO;
        this.expensesNotSettlementMoney = BigDecimal.ZERO;
        this.logisticsTotalWeight = BigDecimal.ZERO;
        this.logisticsMileage = 0;
        this.createDate = date;
        this.createMonth = TimeUtil.getMonth(date);
        this.createYear = TimeUtil.getYear(date);
    }

    public StatisticsCar(Long carId, Date date) {
        this.carId = carId;
        this.logisticsNumber = 0;
        this.logisticsMoney = BigDecimal.ZERO;
        this.logisticsSettlementMoney = BigDecimal.ZERO;
        this.logisticsNotSettlementMoney = BigDecimal.ZERO;
        this.expensesMoney = BigDecimal.ZERO;
        this.expensesSettlementMoney = BigDecimal.ZERO;
        this.expensesNotSettlementMoney = BigDecimal.ZERO;
        this.logisticsTotalWeight = BigDecimal.ZERO;
        this.logisticsMileage = 0;
        this.createDate = date;
        this.createMonth = TimeUtil.getMonth(date);
        this.createYear = TimeUtil.getYear(date);
    }
}
